package cn.com.connext.scrm.utils;

import java.util.Random;

public class RandomUtils {

    /**
     * 生成随机字符串(比方法getRandomString()快)
     *
     * @param length
     * @return
     */
    public static String getRandomString2(int length) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; ++i) {
            int number = random.nextInt(3);
            long ResponseObj = 0;

            switch (number) {
                case 0:
                    ResponseObj = Math.round(Math.random() * 25 + 65);
                    sb.append((char) ResponseObj);
                    break;
                case 1:
                    ResponseObj = Math.round(Math.random() * 25 + 97);
                    sb.append((char) ResponseObj);
                    break;
                case 2:
                    sb.append(new Random().nextInt(10));
                    break;
                default:
            }
        }
        return sb.toString();
    }
}

